package cn.wht.enginee;

import java.io.File;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.BlockingQueue;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * 解析器
 * 
 * @Author: haoting.wang
 * @Date: Created in 上午10:51 2017/6/16
 */
public abstract class ParseEnginee implements Runnable {

    protected BlockingQueue<Map> queue;
    protected File               file;
    public static Map            DUMMY  = new HashMap();
    protected static Logger      logger = LoggerFactory.getLogger(TextParseEnginee.class);

    @Override
    public void run() {
        try {
            parseFileToQueue(queue, file);
        } catch (Exception e) {
            logger.error("read txtFileName error, parse excel quit because :" + e.getMessage(), e);
            try {
                Thread.interrupted();
            } catch (Exception ee) {
            }
        } finally {
            try {
                queue.put(DUMMY);
            } catch (Exception ex) {
            }
        }
    }

    public abstract void parseFileToQueue(BlockingQueue<Map> queue, File file);

}
